#include <iostream>
using namespace std;
int main(){
	double value;
	double store[10000];
	double mean;
	double median;
	int size;
	cout<<"How many values would you like enter?"<<endl;
	cin>>size;
	if (size>=10000)
		size=10000;
	system("cls");
	cout<<"Enter the values:"<<endl;
	for (int counter=0; counter<size; counter++){
		cin>>value;
		store[counter]=value;
		mean=store[counter]+mean;
	}
	double temp;
	bool swapstop;
	for (int redux=0;redux<size;redux++){
		swapstop=true;
		for (int counter2=0; counter2<size-redux-1; counter2++){
			if (store[counter2]>store[counter2+1]){
				temp=store[counter2+1];
				store[counter2+1]=store[counter2];
				store[counter2]=temp;
				swapstop=false;
			}
		}
		if (swapstop)
			redux=size;
	}
	if (size%2!=0)
		median=store[size/2];
	else
		median=(store[(size+1)/2]+store[(size-1)/2])/2;
	double modelevel=1;//the frequency of the most common integer
	double mode=store[0];//the most common integer
	double modeleveltemp;//stores the freqency of the value being checked
	bool existmode=true;//exists to prevent mode from existing if integers tie for being most frequent
	for (int counter3=0; counter3<size;counter3++){
		modeleveltemp=0;
		for(int counter4=0; counter4<size;counter4++){
			if (store[counter3]==store[counter4])
				modeleveltemp++;
		}
		if (modeleveltemp>modelevel){
			modelevel=modeleveltemp;
			mode=store[counter3];
			existmode=true;
		}
		if (modeleveltemp==modelevel && store[counter3]!=mode)
			existmode=false;
	}
	system("cls");
	cout<<"Maximum: "<<store[size-1]<<endl;
	cout<<"Minimum: "<<store[0]<<endl;
	cout<<"Range: "<<store[size-1]-store[0]<<endl;
	cout<<"Mean: "<<mean/size<<endl;
	cout<<"Median: "<<median<<endl;
	if (existmode==true)
		cout<<"Mode: "<<mode<<" ("<<modelevel<<")"<<endl;
	for (int counter10=0; counter10<size; counter10++){
		cout<<store[counter10]<<endl;
	}
	system("pause");
	return 0;
}